package com.lzb;

import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;


public class Inc { 
	private static void test(int[]arr) {
        for (int i = 0; i < arr.length; i++) {
            try {
                if (arr[i] % 2 == 0) {
                    throw new NullPointerException();
                } else {
                    System.out.print(i);
                }
            } finally {
                System.out.print("e");
            }
        }
    }
 
    public static void main(String[] args) throws InterruptedException {
    	final ConcurrentHashMap<String, Boolean> map = new ConcurrentHashMap<String, Boolean>();
    	Thread a = new Thread (){
    	    public void run() {
    	        map.put("first", true);
    	        try {
					Thread.sleep(new Random().nextInt(3) * 1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
    	        map.put("second", true);
    	        System.out.println("put done");
    	    }
    	};

    	Thread b = new Thread() {
    	    public void run() {
    	    	try {
					Thread.sleep(new Random().nextInt(3) * 1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
    	        map.clear();
    	        System.out.println("clear done");
    	    }
    	};

    	a.start();
    	a.join();
    	b.start();
    	b.join();
    	
    	System.out.println(map);
    }
    
    int i;
    int j;
    public void doSomething() {
    	int i;
    	byte a1 = 2, a2 = 4, a3;
    	short s = 16;
    	//a2 = s;
    	//a3 = a1 * a2;
    }
 
}